package mblog;

import java.io.File;
import java.io.PrintStream;
import javax.servlet.MultipartConfigElement;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MultipartConfig
{
  @Bean
  MultipartConfigElement multipartConfigElement()
  {
    MultipartConfigFactory factory = new MultipartConfigFactory();
    String location = System.getProperty("user.dir") + "/data/tmp";
    System.out.println(" location " + location);
    File tmpFile = new File(location);
    if (!tmpFile.exists()) {
      tmpFile.mkdirs();
    }
    factory.setLocation(location);
    return factory.createMultipartConfig();
  }
}
